package com.upcode.weighing.vo.req.pc;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper=false)
@ApiModel(value = "营销注册统计报表查询请求Vo",description = "营销注册统计报表查询请求Vo")
public class OnlineOrderReportReqVo implements Serializable {
    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    @ApiModelProperty(value = "机构编码(营销机构)")
    private String orgCode;

    @ApiModelProperty(value = "订单时间-开始")
    private String orderStartTimeStr;
    @ApiModelProperty(hidden = true)
    private LocalDateTime orderStartTime;

    @ApiModelProperty(value = "订单时间-结束")
    private String orderEndTimeStr;
    @ApiModelProperty(hidden = true)
    private LocalDateTime orderEndTime;

    @ApiModelProperty(value = "查询类型 分页:PAGE, 列表:LIST", hidden = true)
    private String queryType;

    @ApiModelProperty(value = "营销机构编码集合", hidden = true)
    private List<String> marketOrgCodeList;

    /**
     * 时间格式转化
     */
    public void initTime() {
        if (StringUtils.isNotBlank(this.getOrderStartTimeStr())) {
            this.setOrderStartTimeStr(this.getOrderStartTimeStr() + " 00:00:00");
            this.setOrderStartTime(LocalDateTime.parse(this.getOrderStartTimeStr(), DATE_TIME_FORMATTER));
        }
        if (StringUtils.isNotBlank(this.getOrderEndTimeStr())) {
            this.setOrderEndTimeStr(this.getOrderEndTimeStr() + " 23:59:59");
            this.setOrderEndTime(LocalDateTime.parse(this.getOrderEndTimeStr(), DATE_TIME_FORMATTER));
        }
    }
}
